<template>
	<view class="container">
		<!-- 顶部标签页保持不变 -->
		<view style="width: 100%; background-color: #fff; position: sticky; top: 0; z-index: 999;">
			<view class="con">
				<van-tabs :active="active" title-active-color="#3c91ff" title-inactive-color="#000000" color="#3c91ff"
					@change="onChange">
					<van-tab name="1" title="全部订单"></van-tab>
					<van-tab name="2" title="我的订单"></van-tab>
					<van-tab name="3" title="我帮助的"></van-tab>
					<van-tab name="4" title="正在悬赏"></van-tab>
				</van-tabs>
			</view>

			<view class="second-tab con">
				<van-tabs :active="runactive" title-active-color="#3c91ff" title-inactive-color="#333333"
					color="#3c91ff" @change="onRunChange" border="false">
					<van-tab v-for="item in runners" :key="item.tpid" :title="item.txt" :name="item.tpid"></van-tab>
				</van-tabs>
			</view>
		</view>

		<!-- 订单列表 - 移除下拉刷新相关属性 -->
		<scroll-view scroll-y @scroll="handleScroll" class="order-list-container" :style="{ height: scrollViewHeight }">
			<view v-if="ordersList.length === 0 && !loading" class="empty-order-list">
				<text class="empty-text">暂无订单</text>
			</view>
			<view v-for="(order, index) in ordersList" :key="order.id" class="order-item relative"
				@click="showOrderDetail(order.id, order.typeid, order)" :ref="`orderItem${index}`">
				<!-- 订单状态显示在右上角 -->
				<view class="order-status-container">
					<text class="order-status enlarged-status"
						:class="getStatusClass(order.orderStatus)">{{mapStatus(order.orderStatus)}}</text>
				</view>

				<view class="order-basic-info">
					<view class="order-user-avatar">
						<!-- 头像显示使用headImg属性 -->
						<image :src="order.headImg || order.avatar_text" mode="aspectFill" class="user-avatar"></image>
					</view>
					<view class="order-title-container">
						<text class="order-title">{{order.title}}</text>
					</view>
				</view>

				<!-- 带标签的快递类型、数量、性别限制 -->
				<view class="order-extra-info">
					<text class="order-type-label">快递类型：</text>
					<text class="order-type">{{order.type}}</text>
					<text class="order-quantity-label">快递数量：</text>
					<text class="order-quantity">{{order.num}}个</text>
					<text class="order-gender-restriction">{{order.genderRestriction || '不限'}}</text>
				</view>



				<!-- 起点和终点模块 -->
				<view class="order-place-info enlarged-place">
					<view class="order-place-item order-start-with-price">
						<view class="order-place-btn start-btn">起</view>
						<text class="order-start-place">{{order.startPlace}}</text>
						<text class="order-price">¥{{order.reward}}</text>
					</view>
					<view class="order-place-item">
						<view class="order-place-btn end-btn">终</view>
						<text class="order-end-place">{{order.endPlace}}</text>
					</view>
				</view>


				<!-- 状态对应操作按钮 -->
				<view class="order-actions" v-if="order.orderStatus !== '3'">
					<button class="action-btn" v-if="order.orderStatus === '1'" @click.stop="orderOn(order.id)">
						接单
					</button>
					<button class="action-btn" v-if="order.orderStatus === '1' && order.userId == currentUserId"
						@click.stop="refundOrder(order)">
						退款
					</button>

					<!-- 订单列表项中的操作按钮 -->
					<view class=" order-actions" v-if="order.orderStatus === '4'">
						<!-- 当前用户是接单人 -->
						<button class="action-btn" v-if="order.getuid === Number(currentUserId)"
							@click="showOrderAction(order.id, 'processing')">
							查看进度
						</button>

						<!-- 新增：接单人完成订单按钮 -->
						<button class="action-btn complete-btn" v-if="order.getuid === Number(currentUserId)"
							@click.stop="completeOrder(order.id,order)">
							完成订单
						</button>

						<!-- 当前用户是发布人 -->
						<button class="action-btn" v-if="order.userId == Number(currentUserId)"
							@click="showOrderDetail(order.id, order.typeid, order)">
							订单详情
						</button>
					</view>
				</view>
			</view>

			<!-- 加载更多提示 -->
			<view v-if="noMoreData" class="loading-container">
				<text class="loading-text">没有更多数据了</text>
			</view>
			<view v-else-if="loading" class="loading-container">
				<text class="loading-text">加载中...</text>
			</view>
		</scroll-view>

		<!-- 订单详情模态框 -->
		<view v-if="showDetail" class="detail-modal" @touchmove.stop>
			<view class="detail-content">
				<view class="neiRong">
					<!-- 头部 - 头像显示使用headImg属性 -->
					<view class="header">
						<view class="avatar">
							<image :src="currentOrder.headImg || currentOrder.user?.headImg || currentOrder.userAvatar"
								mode="aspectFit"></image>
						</view>
						<text class="title">{{currentOrder.user?.nickname || currentOrder.userName}}</text>
						<text class="time">{{currentOrder.createtime_text || currentOrder.time}}</text>
						<view v-if="currentOrder.orderStatus == '0'" class="status">
							<text>待支付</text>
						</view>
						<view v-else-if="currentOrder.orderStatus == '1'" class="status">
							<text>待帮助</text>
						</view>
						<view v-else-if="currentOrder.orderStatus == '2'" class="status2">
							<text>已帮助</text>
						</view>
						<view v-else-if="currentOrder.orderStatus == '3'" class="status3">
							<text>{{currentOrder.getuid === currentUserId ? '已帮助' : '已完成'}}</text>
						</view>
						<view v-else-if="currentOrder.orderStatus == '4'" class="status4">
							<text>进行中</text>
						</view>
					</view>

					<!-- 快递详情 -->
					<view class="card">
						<view class="card-content">
							<view class="row">
								<text class="label">服务类型：</text>
								<text class="value">{{currentOrder.type || '未知类型'}}</text>
							</view>
							<view class="row">
								<text class="label">物品数量：</text>
								<text class="value">{{currentOrder.num || '0'}}个</text>
							</view>
							<view class="row">
								<text class="label">接单人限制：</text>
								<text class="value">{{currentOrder.genderRestriction || '不限'}}</text>
							</view>
							<view class="row" v-if="currentOrder.price">
								<text class="label">金额：</text>
								<text class="value">{{currentOrder.price}}</text>
							</view>

							<view class="row" v-if="currentOrder.qwsd">
								<text class="label">期望送达：</text>
								<text class="value">{{currentOrder.qwsd}}</text>
							</view>

						</view>
					</view>

					<view v-if="currentOrder.orderStatus == '3' || currentOrder.orderStatus == '2'">
						<text style="color:#3c91ff;margin:20px;">订单已完成，相关信息已隐藏</text>
						<view class="flexRight">
							<button class="btn phone" @click="showServerPhone">
								<image src="/static/image/phone.png" class="phone-icon" />
							</button>
						</view>
					</view>
					<view v-else>
						<!-- 取件信息 -->
						<view class="card">
							<view class="address-box">
								<view class="address-item" v-if="currentOrder.pickadd">
									<text class="tag start">起</text>
									<text class="location">{{currentOrder.pickadd}}</text>
								</view>
								<view class="address-item" v-if="currentOrder.address">
									<text class="tag end">终</text>
									<text class="location">{{currentOrder.address}}</text>
								</view>
							</view>
						</view>

						<!-- 功能按钮 -->
						<view class="card">
							<view class="button-row">
								<view class="button-row">
									<button class="btn note" @tap="showOrderNote">订单备注</button>
									<button class="btn image" @tap="showImage">图片信息</button>
									<button class="btn add-reward" @tap="addRewardAmount"
										v-if="currentOrder.orderStatus == '1' && currentOrder.userId == currentUserId">
										追加金额
									</button>
								</view>
								<button class="btn phone" @click="showServerPhone">
									<image src="/static/image/phone.png" class="phone-icon" />
								</button>
							</view>
						</view>

					</view>
				</view>

				<!-- 接单人信息区域 - 修改显示条件 -->
				<view v-if="currentOrder.getuid !== null">
					<view class="order-info-title">接单人信息</view>
					<view class="neiRong jieDan">
						<view class="jieDan">
							<view class="avatar">
								<image
									:src="currentOrder.getuser?.headImg || currentOrder.getuser?.avatar_text || '/static/image/default_avatar.png'"
									mode="aspectFit" />
							</view>
							<text class="title">
								{{currentOrder.receiverName ||  '未填写昵称'}}
							</text>
							<text class="time"></text>
						</view>
						<button class="btn phone" @click="showReceiverPhone">
							<image src="/static/image/phone.png" class="phone-icon" />
						</button>
					</view>
				</view>
				<view v-else>
					<view class="no-receiver-text">当前状态为待帮助，暂无接单人</view>
				</view>
				<!-- 订单信息标题 -->
				<view class="order-info-title">订单信息</view>
				<!-- 订单信息内容 -->
				<view class="neiRong">
					<view class="order-info-container">
						<!-- 订单号 -->
						<view class="info-item">
							<text class="label">订单号</text>
							<view class="value-copy">
								<text class="value">{{currentOrder.repnum}}</text>
								<button class="copy-btn" @tap="copyOrderNumber">
									<image src="/static/image/xy.png" class="copy-icon" />
								</button>
							</view>
						</view>
						<!-- <view class="time">{{formatTime(currentOrder.createtime) || currentOrder.time}}</view> -->
						<view class="info-item">
							<text class="label">支付时间</text>
							<text class="value">{{currentOrder.wxtime}}</text>
						</view>
						<view class="info-item" v-if="currentOrder.gettime">
							<text class="label">接单时间</text>
							<text class="value">{{formatTime(currentOrder.gettime)}}</text>
						</view>
						<view class="info-item" v-if="currentOrder.updatetime">
							<text class="label">完成时间</text>
							<text class="value">{{formatTime(currentOrder.updatetime)}}</text>
						</view>

						<!-- 联系管理员 -->

					</view>
				</view>


			</view>

			<!-- 原有底部返回按钮保持不变 -->
			<view class="detail-footer">
				<view class="btnFather">
					<view style="width:150px" @click="hideDetail">
						<button class="btn back" id="ddzx">返回订单列表</button>
					</view>
					<view style="width:100px"
						v-if="currentOrder.orderStatus == '1' && currentOrder.isEdit !=1 && currentOrder.dele==1"
						@click="orderOn(currentOrder.id)">
						<button class="btn confirm" id="jd">接单</button>
					</view>
				</view>
			</view>
		</view>

		<!-- 对话框 - 保持不变 -->
		<van-dialog use-slot :show="!togs" @confirm="togs = true" :title="title" :z-index="10000">
			<view class="dialog-content" v-if="adminInfo.mobile && type==3">
				电话：{{adminInfo.mobile}}
			</view>
			<view v-else-if="imagePaths && type==2" class="dialog-content">

				<view v-for="(img, index) in imagePaths" :key="index" class="image-container">
					<image :src="img" mode="aspectFit" class="dialog-image"></image>
				</view>
			</view>
			<view v-else-if="currentOrder.remark && type==1" class="dialog-content">
				备注：{{currentOrder.remark}}
			</view>
			<view v-else-if="currentOrder.user?.mobile && type==4" class="dialog-content">
				电话：{{currentOrder.user?.mobile}}
			</view>
			<view v-else-if="currentOrder.getuser?.mobile && type==5" class="dialog-content">
				电话：{{currentOrder.getuser?.mobile}}
			</view>
			<view v-else class="dialog-content">
				无内容
			</view>
		</van-dialog>

		<!-- 追加金额对话框 - 原生实现 -->
		<view v-if="showAddRewardDialog" class="dialog-overlay" @touchmove.stop>
			<view class="dialog-container">
				<view class="dialog-header">
					<text class="dialog-title">追加订单金额</text>
				</view>
				<view class="dialog-content">
					<view class="form-item">
						<text class="label">当前悬赏金额:</text>
						<text class="value">¥{{currentOrder.reward}}</text>
					</view>
					<view class="form-item">
						<text class="label">追加金额:</text>
						<view class="input-container">
							<text class="currency-symbol">¥</text>
							<input type="digit" v-model.number="rewardAmount" placeholder="请输入追加金额"
								class="amount-input" />
						</view>
					</view>
				</view>
				<view class="dialog-footer">
					<button class="dialog-btn cancel-btn" @click="cancelAddReward">取消</button>
					<button class="dialog-btn confirm-btn" @click="confirmAddReward">确认</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	// 原有script部分保持不变
	import {
		ref,
		onMounted,
		onUnmounted,
		watch,
		nextTick,
		computed
	} from 'vue';
	import {
		showToast,
		onShow,
		onLoad
	} from '@dcloudio/uni-app';
	import {
		getCampusOrder,
		jieCampusOrder,
		updateAdditionalAmount,
		getPaymentInfoSan,
		addorderRewardAddition,
		updateOrderrewardAmount,
		getYueZhiFu,
		refund,
		useBalancePayRefund,
		deleteCamorder,
		deleteCampusOrder,
		wanChengCompleteOrder,
		isJieDanStatus
	} from "@/api/index.js";


	// 在 script setup 顶部添加响应式变量定义
	const imagePaths = ref([]); // 存储图片路径数组
	// 状态管理
	const active = ref(1);
	const currentPage = ref(1); // 当前页码，初始为1
	const pageSize = ref(10); // 每页10条数据
	const runactive = ref(1);
	const runners = [{
		txt: "全部",
		tpid: 1
	}];

	// 新增：时间格式化函数
	// 增强版时间格式化函数（精确到年月日时分秒）
	const formatTime = (timestamp) => {
		console.log("格式化时间戳:", timestamp);

		// 处理无效时间戳
		if (!timestamp || timestamp === 0) {
			console.log("无效时间戳，返回空字符串");
			return '';
		}

		// 自动识别时间戳类型（秒级或毫秒级）
		// 当前时间戳与系统当前时间比较，差距超过30年则认为是秒级
		const now = Date.now();
		const isSecondLevel = timestamp < now / 1000;

		// 转换为毫秒级
		const normalizedTimestamp = isSecondLevel ? timestamp * 1000 : timestamp;

		// 创建日期对象
		const date = new Date(normalizedTimestamp);

		// 提取年月日
		const year = date.getFullYear();
		const month = (date.getMonth() + 1).toString().padStart(2, '0');
		const day = date.getDate().toString().padStart(2, '0');

		// 提取时分秒
		const hours = date.getHours().toString().padStart(2, '0');
		const minutes = date.getMinutes().toString().padStart(2, '0');
		const seconds = date.getSeconds().toString().padStart(2, '0');

		// 输出格式化结果
		const formattedTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
		console.log("格式化结果:", formattedTime);

		return formattedTime;
	};


	const ordersList = ref([]);
	const showDetail = ref(false);
	const currentOrder = ref({});
	const togs = ref(true);
	const adminInfo = ref({});
	const type = ref();
	const title = ref('');
	const loading = ref(false);
	const noMoreData = ref(false);
	const isLoading = ref(false);
	const scrollViewHeight = ref('100%');

	// 当前登录用户ID（示例值，实际应从存储或API获取）
	const currentUserId = ref();

	// 新增：追加金额相关状态
	const rewardAmount = ref(0); // 追加金额
	const showAddRewardDialog = ref(false); // 是否显示追加金额对话框

	// 新增：当前筛选条件
	const currentFilters = ref({
		orderStatus: null, // 订单状态筛选
		orderType: null, // 订单类型筛选
		// 可以添加更多筛选条件...
	});

	// 判断当前用户是否是接单人
	const isCurrentUserReceiver = computed(() => {
		return currentOrder.value.getuid === currentUserId.value;
	});

	// 动态加载相关
	const screenHeight = ref(0);
	const itemHeight = ref(450); // 单个订单高度
	const itemsPerScreen = ref(2); // 一屏显示2个订单
	const scrollTimer = ref(null);
	const scrollDebounceTime = ref(200);
	const triggerDistance = ref(300); // 触发加载的距离
	const forceLoadMore = ref(false); // 强制加载标志

	// 状态映射函数 - 直接使用orderStatus
	const mapStatus = (orderStatus) => {
		switch (orderStatus) {
			case '0':
				return '待支付';
			case '1':
				return '待帮助';
			case '2':
				return '已帮助';
			case '3':
				return '已完成';
			case '4':
				return '进行中';
			default:
				return '未知状态';
		}
	};

	// 获取状态样式
	const getStatusClass = (orderStatus) => {
		switch (orderStatus) {
			case '0':
			case '1':
				return 'status-pending enlarged-status';
			case '2':
			case '4':
				return 'status-accepted enlarged-status';
			case '3':
				return 'status-completed enlarged-status';
			default:
				return '';
		}
	};

	// 页面显示时加载数据
	onShow(() => {
		// login_data
		currentUserId.value = uni.getStorageSync('login_data').uid
		console.log(currentUserId.value)
		console.log(uni.getStorageSync('login_data'))
		console.log('页面显示，加载订单列表');
		resetPagination();
		getOrderData(1, true); // 从第1页开始加载
		setScrollViewHeight();
	});
	onLoad(() => {
		// login_data
		currentUserId.value = uni.getStorageSync('login_data').uid
	});

	// 重置分页状态 - 强化清空逻辑
	const resetPagination = () => {
		currentPage.value = 1; // 重置页码为1
		noMoreData.value = false;
		ordersList.value = []; // 清空订单列表
	};

	// 设置滚动视图高度
	const setScrollViewHeight = () => {
		uni.getSystemInfo({
			success: (res) => {
				scrollViewHeight.value = `${res.windowHeight - 100}px`;
				screenHeight.value = res.windowHeight - 100;
				calculateItemsPerScreen();
			},
			fail: (err) => {
				console.error('获取系统信息失败', err);
				scrollViewHeight.value = 'calc(100vh - 300rpx)';
				screenHeight.value = uni.upx2px(750) - 100;
			}
		});
	};

	// 计算一屏可显示的订单数量
	const calculateItemsPerScreen = () => {
		if (screenHeight.value > 0 && itemHeight.value > 0) {
			itemsPerScreen.value = Math.ceil(screenHeight.value / itemHeight.value);
			console.log(`一屏可显示 ${itemsPerScreen.value} 个订单，每页加载 ${pageSize.value} 条`);
		}
	};

	// 标签页切换逻辑修复 - 保存筛选条件
	const onChange = (e) => {
		console.log('标签页切换，新标签:', e.detail.name);
		resetPagination(); // 清空订单列表和重置分页状态

		// 重置筛选条件
		currentFilters.value = {
			orderStatus: null,
			orderType: null
		};

		// 显示加载状态
		uni.showLoading({
			title: '加载中...'
		});

		// 明确筛选条件
		let filterType = null;
		let apiFilter = {};

		switch (e.detail.name) {
			case '2': // 我的订单：发布人ID匹配
				filterType = 'myOrders';
				apiFilter.userId = currentUserId.value;
				currentFilters.value.userId = currentUserId.value;
				currentFilters.value.orderStatus = null; // 重置状态筛选
				break;
			case '3': // 我帮助的：接单人ID匹配
				filterType = 'helpedOrders';
				apiFilter.receiverId = currentUserId.value; // 明确设置接单人ID筛选
				currentFilters.value.receiverId = currentUserId.value;
				currentFilters.value.orderStatus = null; // 重置状态筛选
				break;
			case '4': // 正在悬赏：未被接单的订单
				filterType = 'pendingOrders';
				apiFilter.orderStatus = 1;
				currentFilters.value.orderStatus = 1; // 保存筛选条件
				break;
			default: // 全部订单：不筛选
				filterType = 'allOrders';
				currentFilters.value.orderStatus = null;
		}

		// 加载对应订单
		getOrderData(1, true, filterType, apiFilter).then(() => {
			uni.hideLoading();
		}).catch(() => {
			uni.hideLoading();
		});
	};

	// 二级标签页切换 - 添加类型筛选
	const onRunChange = (e) => {
		console.log('二级标签页切换，新标签:', e.detail.name);
		resetPagination();

		// 更新订单类型筛选条件
		currentFilters.value.orderType = e.detail.name;

		// 根据二级标签页类型设置订单状态筛选
		if (e.detail.name === 1) { // 全部
			currentFilters.value.orderStatus = null;
		} else if (e.detail.name === 2) { // 宿舍超市
			currentFilters.value.orderStatus = null;
		}

		// 加载对应订单
		getOrderData(1, true, null, {
			orderType: e.detail.name,
			orderStatus: currentFilters.value.orderStatus
		});
	};

	// 数据预处理函数 - 确保订单包含发布人/接单人ID
	const processOrderData = (data) => {
		console.log(data)
		return data.map(order => {
			const orderTypeMap = {
				'1': '快递代取',
				'2': '快递代寄',
				'3': '外卖代拿',
				'4': '校园跑腿',
				'5': '垃圾代扔',
				'6': '代写服务'
			};

			const genderMap = {
				'1': '仅限男生',
				'2': '仅限女生'
			};

			// 格式化时间戳为可读格式
			const formatTime = (timestamp) => {
				if (!timestamp) return '';
				const date = new Date(timestamp * 1000); // 假设时间戳是秒级
				return date.toLocaleString();
			};

			return {
				id: order.id,
				headImg: order.headImg || `https://picsum.photos/seed/user${order.userId}/200/200`,
				title: orderTypeMap[order.orderType + ''] || '未知类型',
				reward: (order.payAmount || 0).toFixed(2),
				orderStatus: order.orderStatus + '', // 确保orderStatus是字符串
				type: orderTypeMap[order.orderType + ''] || '未知类型',
				startPlace: order.startPlace || '起点-' + order.id,
				endPlace: order.endPlace || '终点-' + order.id,
				num: order.expressNum || 1,
				genderRestriction: genderMap[order.receiverSex + ''] || '不限',
				remark: order.pickupInfo || '无特殊要求',
				repnum: order.orderNo || `ORD-${Math.floor(Math.random() * 100000000)}`,
				user: {
					id: order.userId,
					nickname: order.user?.nickname || `用户${order.userId}`,
					mobile: order.user?.mobile ||
						`13${Math.floor(Math.random() * 9)}${Math.floor(Math.random() * 100000000).toString().padStart(9, '0')}`
				},
				getuser: order.receiver ? {
					id: order.receiverId,
					nickname: order.receiver?.nickname || '匿名接单员',
					mobile: order.receiver?.mobile ||
						`130${Math.floor(Math.random() * 10000000).toString().padStart(7, '0')}`,
					headImg: order.receiver?.headImg || order.receiver?.avatar_text || null
				} : null,
				getuid: order.receiverId || null,
				userId: order.userId, // 明确发布人ID
				time: order.time || Math.floor(Math.random() * 86400 * 1000),
				state: order.orderStatus || '0', // 保留state字段用于兼容
				// 接单人信息
				receiverName: order.receiverName,
				receiverPhone: order.receiverPhone,

				// 新增：格式化时间字段
				createtime_text: formatTime(order.createTime),
				wxtime_text: formatTime(order.payTime),
				gettime_text: formatTime(order.acceptTime),
				updatetime_text: formatTime(order.completeTime),

				// 原始时间戳
				createtime: order.createTime,
				wxtime: order.payTime,
				gettime: order.acceptTime,
				updatetime: order.completeTime,
				additionalAmount: order.additional_amount,
				paymentType: order.paymentType,
				imageInfo: order.imageInfo || '' // 确保imageInfo存在
			};
		});
	};

	// 修改getOrderData函数以接收额外筛选条件
	const getOrderData = async (pageNum = 1, isRefresh = false, filterType = null, apiFilter = {}) => {
		if (isLoading.value || (noMoreData.value && !forceLoadMore.value)) return;

		isLoading.value = true;
		loading.value = true;

		try {
			// 合并当前筛选条件和传入的API筛选条件
			const finalFilters = {
				...currentFilters.value,
				...apiFilter
			};

			const datas = {
				depid: uni.getStorageSync("school_id"),
				page: pageNum, // 使用page参数
				pageSize: pageSize.value, // 每页数量
				schoolId: currentUserId.value, // 传递当前用户ID用于筛选
				...finalFilters // 添加筛选条件
			};

			console.log('请求参数:', datas);
			const response = await getCampusOrder(JSON.stringify(datas));
			console.log('API响应 - 页码:', pageNum, '每页数量:', pageSize.value,
				'筛选类型:', filterType, '响应数据:', response.data, '是否有下一页:', response.data?.hasNextPage);

			if (response.code === 200 && response.data) {
				console.log("-----------------")
				console.log(response.data)
				const pageResult = response.data;
				const newOrders = processOrderData(pageResult.list || []);
				console.log(newOrders)

				console.log('新数据数量:', newOrders.length);

				// 确保数据正确合并（刷新时替换，加载更多时追加）
				ordersList.value = isRefresh ? newOrders : [...ordersList.value, ...newOrders];
				console.log('当前订单总数:', ordersList.value.length);

				// 更新分页状态
				noMoreData.value = !pageResult.hasNextPage;
				console.log('是否还有更多数据:', !noMoreData.value);

				// 只有当有下一页时才递增页码
				if (!noMoreData.value) {
					currentPage.value = pageNum + 1;
					console.log('当前页码更新为:', currentPage.value);
				}
			} else {
				uni.showToast({
					title: response.msg || '获取订单数据失败',
					icon: 'none'
				});
				noMoreData.value = ordersList.value.length > 0 ? false : true;
			}
		} catch (error) {
			console.error('获取订单数据失败:', error);
			uni.showToast({
				title: '加载订单失败，请重试',
				icon: 'none'
			});
			noMoreData.value = ordersList.value.length === 0;
		} finally {
			loading.value = false;
			isLoading.value = false;
		}
	};

	// 滚动事件处理
	const handleScroll = (e) => {
		if (isLoading.value || noMoreData.value && !forceLoadMore.value) return;

		if (scrollTimer.value) {
			clearTimeout(scrollTimer.value);
		}

		scrollTimer.value = setTimeout(() => {
			const scrollTop = e.detail.scrollTop;
			const scrollHeight = e.detail.scrollHeight;
			const clientHeight = e.detail.scrollWidth;

			const distanceToBottom = scrollHeight - scrollTop - clientHeight;
			console.log('滚动事件 - 距离底部:', distanceToBottom, '触发距离:', triggerDistance.value,
				'有下一页:', !noMoreData.value, '当前页码:', currentPage.value);

			if ((distanceToBottom < triggerDistance.value && !noMoreData.value) || forceLoadMore.value) {
				console.log('触发加载更多数据');
				loadMore();
			}
		}, scrollDebounceTime.value);
	};

	// 加载更多数据
	const loadMore = () => {
		console.log('执行加载更多 - 当前页码:', currentPage.value);
		// 使用当前筛选条件加载更多数据
		getOrderData(currentPage.value, false, null, currentFilters.value);
	};

	// 测量订单项高度
	const measureItemHeight = () => {
		if (ordersList.value.length === 0) return;

		uni.createSelectorQuery()
			.select(`.order-item`)
			.boundingClientRect((rect) => {
				if (rect && rect.height) {
					itemHeight.value = rect.height;
					calculateItemsPerScreen();
				} else {
					itemHeight.value = 450;
					calculateItemsPerScreen();
				}
			})
			.exec();
	};

	// 显示订单详情
	const showOrderDetail = (orderId, typeid, order) => {
		console.log(order)
		console.log('显示订单详情，订单ID:', orderId);
		setTimeout(() => {
			const order = ordersList.value.find(o => o.id === orderId);
			if (order) {
				currentOrder.value = {
					...order
				};
				showDetail.value = true;
				console.log(currentOrder.value)
			}
		}, 300);
	};

	// 其他功能函数保持不变
	const hideDetail = () => {
		showDetail.value = false;
	};

	// 新增权限控制的函数
	const showOrderNote = () => {
		const uid = uni.getStorageSync('login_data').uid
		// 权限判断：当前用户是接单人或发布人
		if (currentOrder.value.getuid == Number(uid) ||
			currentOrder.value.userId == Number(uid)) {
			console.log("---")
			togs.value = false;
			type.value = 1;
			title.value = "订单备注";
		} else {
			uni.showToast({
				title: '只限接单人和发布人进行查看',
				icon: 'none'
			});
		}
	};

	// 新增权限控制的函数
	const showImage = () => {
		const uid = uni.getStorageSync('login_data').uid
		// 权限判断：当前用户是接单人或发布人
		if (currentOrder.value.getuid === Number(uid) ||
			currentOrder.value.userId === Number(uid)) {
			// 处理图片路径，按逗号分割
			const imageInfo = currentOrder.value.imageInfo || '';
			console.log(currentOrder.value)
			console.log(imageInfo)
			imagePaths.value = imageInfo.split(',').filter(path => path.trim() !== '');
			togs.value = false;
			type.value = 2;
			title.value = "图片信息";
		} else {
			uni.showToast({
				title: '只限接单人和发布人进行查看',
				icon: 'none'
			});
		}
	};

	const contactAdmin = () => {
		adminInfo.value = {
			mobile: `18${Math.floor(Math.random() * 9)}${Math.floor(Math.random() * 100000000).toString().padStart(9, '0')}`
		};
		togs.value = false;
		type.value = 3;
		title.value = "联系校区管理员";
	};
	const showServerPhone = () => {
		togs.value = false;
		type.value = 4;
		title.value = "发单人电话";
	};

	const showReceiverPhone = () => {
		togs.value = false;
		type.value = 5;
		title.value = "接单人电话";
	};

	const orderOn = async (orderId) => {
		console.log(orderId)

		// 判断发布人ID和当前登录用户ID是否一致
		const order = ordersList.value.find(o => o.id === orderId);
		if (!order) return;
		const id = uni.getStorageSync('login_data').uid || currentUserId.value;

		if (order.userId == id) {
			uni.showToast({
				title: '不能接自己发布的订单',
				icon: 'none'
			});
			return; // 关键修改：添加return语句，阻止后续操作
		}
		const jie = await isJieDanStatus();
		if (jie.data != 200) {
			uni.showToast({
				title: '暂无接单资格',
				icon: 'none'
			});
			return; // 关键修改：添加return语句，阻止后续操作
		}
		console.log(uni.getStorageSync('login_data'))
		const data = {
			id: orderId,
			// 接单人名称
			receiverName: uni.getStorageSync('login_data').nikeName,
			// 接单人电话
			receiverPhone: uni.getStorageSync('login_data').phone,
		}

		const res = await jieCampusOrder(JSON.stringify(data));
		console.log(res)

		// 调用接单API（示例，实际应替换为真实API调用）
		uni.showToast({
			title: '接单成功',
			icon: 'success'
		});

		// 更新订单状态
		const index = ordersList.value.findIndex(o => o.id === orderId);
		if (index !== -1) {
			ordersList.value[index].orderStatus = '4';
		}
		order.receiverName = data.receiverName;
		order.receiverPhone = data.receiverPhone;

		// 接单成功后调用 showOrderDetail 方法显示订单详情
		showOrderDetail(orderId, order.typeid, order);
	};

	// 新增：追加金额函数
	const addRewardAmount = () => {
		console.log('点击了追加金额按钮');
		rewardAmount.value = 0; // 重置追加金额
		showAddRewardDialog.value = true; // 显示对话框
	};

	// 新增：确认追加金额
	const confirmAddReward = async () => {
		if (rewardAmount.value <= 0) {
			uni.showToast({
				title: '请输入有效的追加金额',
				icon: 'none'
			});
			return;
		}

		try {
			// 获取当前订单ID（确保是ID而不是编号）
			const orderId = currentOrder.value.id;
			console.log('确认追加金额 - 订单ID:', orderId, '追加金额:', rewardAmount.value);
			const orderNo = currentOrder.value.repnum;
			console.log(orderNo)

			const data = {
				orderNumber: orderNo, // 使用正确的订单ID
				additionalAmount: rewardAmount.value // 追加金额
			};

			// 调用追加金额API
			const response = await addorderRewardAddition(JSON.stringify(data));

			if (response.data > 0) {
				// 唤起支付方式

				// 3秒后显示支付选项
				setTimeout(() => {
					// 唤起让用户选择微信支付还是余额支付
					uni.showActionSheet({
						itemList: ['微信支付', '余额支付'],
						success: (res) => {
							if (res.tapIndex === 0) {
								handleWechatPay(currentOrder.value, rewardAmount
									.value, response.data); // 微信支付
							} else if (res.tapIndex === 1) {
								handleBalancePay(currentOrder.value, rewardAmount
									.value, response.data); // 余额支付
							}
						},
						fail: (err) => {
							console.log(err);
						}
					});
				}, 1000)

				showAddRewardDialog.value = false;
			} else {
				uni.showToast({
					title: response.msg || '追加金额失败',
					icon: 'none'
				});
			}
		} catch (error) {
			console.error('追加金额失败:', error);
			uni.showToast({
				title: '操作失败，请重试',
				icon: 'none'
			});
		}
	};

	// 微信支付处理函数
	const handleWechatPay = async (currentOrder, rewardAmount, response) => {
		console.log(currentOrder)
		console.log(rewardAmount)

		try {
			let payData = {
				uni: response,
			}
			let payres = await getPaymentInfoSan(payData);
			console.log(payres, 123)
			if (payres.code == 200) {
				wx.requestPayment({
					timeStamp: payres.data.jsConfig.timeStamp,
					nonceStr: payres.data.jsConfig.nonceStr,
					package: payres.data.jsConfig.packageVal,
					paySign: payres.data.jsConfig.paySign,
					signType: payres.data.jsConfig.signType, // 该参数为固定值
					success(res) {
						uni.showToast({
							title: '支付成功',
							icon: 'none'
						})

						// 支付成功后更新订单金额
						const orderId = currentOrder.id;
						const orderIndex = ordersList.value.findIndex(o => o.id === orderId);
						if (orderIndex !== -1) {
							// 更新订单列表中的金额
							const newReward = parseFloat(ordersList.value[orderIndex].reward) + parseFloat(
								rewardAmount.value);
							ordersList.value[orderIndex].reward = newReward.toFixed(2);

							// 更新当前显示的订单详情
							currentOrder.value.reward = newReward.toFixed(2);
						}

						// 根据订单id修改支付金额  刷新页面
						let data = {
							id: currentOrder.id,
							payAmount: rewardAmount
						}
						console.log(data)
						updateOrderrewardAmount(JSON.stringify(data))
					},
					fail(err) {
						// 支付失败回调
						console.error('唤起支付组件失败：', err);
						uni.showToast({
							title: '支付失败',
							icon: 'none'
						})
					}
				});
			}
		} catch (error) {
			console.error('微信支付处理异常:', error);
			uni.showToast({
				title: '支付处理失败，请重试',
				icon: 'none'
			});
		}
	};

	// 余额支付处理函数
	const handleBalancePay = async (currentOrder, rewardAmount, response) => {
		console.log(currentOrder.id)
		console.log(rewardAmount)
		console.log(response)

		try {
			// 准备余额支付参数
			const yueZhiFuParams = {
				orderNo: response,
				totalAmount: rewardAmount
			};

			// 显示加载中
			uni.showLoading({
				title: '支付处理中...'
			});

			// 调用余额支付接口
			const payRes = await getYueZhiFu(yueZhiFuParams);

			// 隐藏加载
			uni.hideLoading();

			if (payRes.code === 200) {
				// 余额支付成功
				uni.showModal({
					title: '支付结果',
					content: payRes.message || '余额支付成功',
					showCancel: false,
					success: () => {
						// 支付成功后更新订单金额
						const orderId = currentOrder.id;
						const orderIndex = ordersList.value.findIndex(o => o.id === orderId);
						if (orderIndex !== -1) {
							// 更新订单列表中的金额
							const newReward = parseFloat(ordersList.value[orderIndex].reward) +
								parseFloat(rewardAmount.value);
							ordersList.value[orderIndex].reward = newReward.toFixed(2);

							// 更新当前显示的订单详情
							currentOrder.value.reward = newReward.toFixed(2);
						}

						// 根据订单id修改支付金额  刷新页面
						let data = {
							id: currentOrder.id,
							payAmount: rewardAmount
						}
						console.log(data)
						updateOrderrewardAmount(JSON.stringify(data))
					}
				});
			} else if (payRes.code === 400) { // 假设后端余额不足返回400错误
				// 余额不足提示
				uni.showToast({
					title: payRes.message || '账户余额不足，请先充值',
					icon: 'none'
				});
			} else {
				// 其他错误提示
				uni.showToast({
					title: payRes.message || '余额支付失败，请重试',
					icon: 'none'
				});
			}
		} catch (error) {
			console.error('余额支付处理异常:', error);
			uni.hideLoading();
			uni.showToast({
				title: '支付处理失败，请重试',
				icon: 'none'
			});
		}
	};

	// 新增：取消追加金额
	const cancelAddReward = () => {
		showAddRewardDialog.value = false;
	};

	// 新增：完成订单函数
	const completeOrder = async (orderId, order) => {
		uni.showModal({
			title: '确认完成',
			content: '确认该订单已完成？',
			success: async (res) => {
				if (res.confirm) {
					try {

						const response = await wanChengCompleteOrder(JSON.stringify(order));

						if (response.code === 200) {
							uni.showToast({
								title: '订单已完成',
								icon: 'success'
							});

							// 更新本地订单状态
							const index = ordersList.value.findIndex(o => o.id === orderId);
							if (index !== -1) {
								ordersList.value[index].orderStatus = '3';
							}

							// 刷新当前订单详情
							showOrderDetail(orderId, ordersList.value[index].typeid, ordersList.value[
								index]);
						} else {
							uni.showToast({
								title: response.msg || '完成订单失败',
								icon: 'none'
							});
						}
					} catch (error) {
						console.error('完成订单失败:', error);
						uni.showToast({
							title: '操作失败，请重试',
							icon: 'none'
						});
					}
				}
			}
		});
	};

	const copyOrderNumber = () => {
		const repnum = currentOrder.value.repnum;
		uni.setClipboardData({
			data: repnum,
			success: () => uni.showToast({
				title: '订单号已复制!',
				icon: 'none'
			})
		});
	};

	// 确认收货函数
	const confirmReceipt = () => {
		uni.showModal({
			title: '确认收货',
			content: '确认该订单已完成并收货？',
			success: (res) => {
				if (res.confirm) {
					// 调用确认收货API
					console.log('调用确认收货API，订单ID:', currentOrder.value.id);

					// 模拟API成功响应
					setTimeout(() => {
						currentOrder.value.orderStatus = '3'; // 更新订单状态为已完成

						// 更新订单列表中的对应订单状态
						const index = ordersList.value.findIndex(o => o.id === currentOrder.value
							.id);
						if (index !== -1) {
							ordersList.value[index].orderStatus = '3';
						}

						uni.showToast({
							title: '确认收货成功',
							icon: 'success'
						});
					}, 500);
				}
			}
		});
	};



	// 退款
	const refundOrder = async (order) => {
		console.log('执行退款操作，订单信息:', order);

		// 显示确认对话框
		uni.showModal({
			title: '确认退款',
			content: `确定要退款吗？退款金额：¥${order.reward}`,
			success: async (res) => {
				if (res.confirm) {
					try {
						// 显示加载中
						uni.showLoading({
							title: '处理中...'
						});

						let response;
						let refundDataToUse = null; // 声明一个变量用于存储退款数据，扩大其作用域



						if (order.paymentType == 0) {
							// 微信退款
							const refundData = {
								orderNo: order.id, // 订单编号
								refundAmount: parseFloat(order.reward) // 退款金额
							};

							console.log('微信退款请求参数:', refundData);
							refundDataToUse = refundData;
							response = await refund(order.id, parseFloat(order.reward));

						} else {
							// 余额退款
							const balanceRefundData = {
								id: order.id, // 订单ID
								userId: order.userId, // 用户ID
								payAmount: parseFloat(order.reward) // 支付金额
							};

							console.log('余额退款请求参数:', balanceRefundData);
							response = await useBalancePayRefund(balanceRefundData);
						}

						console.log('退款API响应:', response);

						if (response.code === 200) {
							// 退款成功
							uni.showToast({
								title: '退款成功',
								icon: 'success'
							});
							// 发送请求进行删除订单
							await deleteCampusOrder(JSON.stringify(refundDataToUse))




							// 刷新列表
							resetPagination();
							getOrderData(1, true);

						} else {
							// 退款失败
							uni.showToast({
								title: response.msg || '退款失败',
								icon: 'none'
							});
						}

					} catch (error) {
						console.error('退款请求异常:', error);
						uni.showToast({
							title: '退款处理异常，请重试',
							icon: 'none'
						});
					} finally {
						uni.hideLoading();
					}
				}
			}
		});
	};


	// 生命周期钩子
	onMounted(() => {
		console.log('页面挂载');
		if (ordersList.value.length === 0) {
			getOrderData(1);
		}
	});

	onUnmounted(() => {
		console.log('页面卸载');
		if (scrollTimer.value) {
			clearTimeout(scrollTimer.value);
		}
	});
</script>

<style scoped>
	/* 订单列表样式 */
	.order-list-container {
		padding-bottom: 100rpx;
	}

	.order-item {
		background-color: #fff;
		border-radius: 10rpx;
		padding: 30rpx;
		margin: 20rpx;
		box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
		position: relative;
		overflow: hidden;
		height: 450rpx;
		/* 增加单个订单高度，确保一屏显示2个 */
	}

	/* 空订单列表样式 */
	.empty-order-list {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		height: 300rpx;
		color: #999;
	}

	.empty-text {
		font-size: 28rpx;
	}

	/* 订单状态和价格容器 */
	.order-status-container {
		position: absolute;
		top: 20rpx;
		right: 20rpx;
		z-index: 1;
	}

	.order-status {
		font-size: 32rpx;
		padding: 8rpx 24rpx;
		border-radius: 30rpx;
		font-weight: 500;
	}

	.enlarged-status {
		font-size: 32rpx !important;
		padding: 8rpx 24rpx !important;
	}

	.status-pending {
		background-color: #e1f3e8;
		color: #07c160;
	}

	.status-accepted {
		background-color: #e9f7ff;
		color: #39a0ef;
	}

	.status-completed {
		background-color: #fff3ea;
		color: #f8ca12;
	}

	.order-basic-info {
		display: flex;
		align-items: center;
		margin-bottom: 20rpx;
	}

	.order-user-avatar {
		width: 80rpx;
		height: 80rpx;
		border-radius: 50%;
		overflow: hidden;
		margin-right: 20rpx;
	}

	.user-avatar {
		width: 100%;
		height: 100%;
	}

	.order-title-container {
		flex: 1;
	}

	.order-title {
		font-size: 32rpx;
		font-weight: bold;
		color: #333;
		display: block;
	}

	/* 新增：带标签的信息样式 */
	.order-extra-info {
		display: flex;
		align-items: center;
		margin-bottom: 20rpx;
		flex-wrap: wrap;
	}

	.order-type-label,
	.order-quantity-label,
	.order-gender-label {
		font-size: 26rpx;
		color: #666;
		font-weight: 500;
	}

	.order-type,
	.order-quantity,
	.order-gender-restriction {
		font-size: 26rpx;
		margin-right: 16rpx;
	}

	.order-type {
		color: #333;
	}

	.order-quantity {
		color: #333;
	}

	.order-gender-restriction {
		color: #ff7d00;
	}

	.order-time-info {
		display: flex;
		justify-content: flex-start;
		align-items: center;
		margin-bottom: 20rpx;
	}

	.order-time-label {
		font-size: 26rpx;
		color: #666;
		font-weight: 500;
		margin-right: 10rpx;
	}

	.order-time {
		font-size: 26rpx;
		color: #999;
	}

	/* 起点和终点模块（价格起点和终点模块（价格显示在起点行最右边） */
	.enlarged-place .order-place-item {
		margin-bottom: 20rpx;
	}

	.enlarged-place .order-place-btn {
		width: 54rpx;
		height: 54rpx;
		line-height: 54rpx;
		font-size: 28rpx;
	}

	.enlarged-place .order-start-place,
	.enlarged-place .order-end-place {
		font-size: 32rpx;
	}

	.order-place-info {
		display: flex;
		flex-direction: column;
	}

	.order-place-item {
		display: flex;
		align-items: center;
		margin-bottom: 15rpx;
	}

	.order-start-with-price {
		justify-content: space-between;
	}

	.order-place-btn {
		width: 44rpx;
		height: 44rpx;
		border-radius: 50%;
		text-align: center;
		line-height: 44rpx;
		margin-right: 20rpx;
		font-weight: bold;
	}

	.start-btn {
		background: #07c160;
		color: #fff;
	}

	.end-btn {
		background: #1989fa;
		color: #fff;
	}

	.order-start-place,
	.order-end-place {
		font-size: 28rpx;
		color: #333;
		flex: 1;
	}

	/* 价格样式 */
	.order-price {
		font-size: 36rpx;
		font-weight: bold;
		color: #ff5500;
		margin-left: 20rpx;
	}

	.order-actions {
		position: absolute;
		bottom: 20rpx;
		right: 20rpx;
		display: flex;
		/* 改为弹性布局 */
		flex-direction: row;
		/* 主轴为横向 */
		gap: 10rpx;
		/* 按钮间距 */
	}

	.action-btn {
		background-color: #3c91ff;
		color: white;
		border: none;
		border-radius: 8rpx;
		padding: 6rpx 16rpx;
		font-size: 14px;
		white-space: nowrap;
		/* 防止文字换行 */
		min-width: 80rpx;
		flex-shrink: 0;
		/* 不缩小按钮 */
	}

	.complete-btn {
		background-color: #ff5500;
		margin-left: 0;
		/* 移除左侧边距，使用容器的gap */
	}

	/* 订单详情模态框样式 */
	.detail-modal {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, 0.5);
		display: flex;
		justify-content: center;
		align-items: center;
		z-index: 9999;
		padding-top: 0;
		box-sizing: border-box;
		overflow: hidden;
	}

	.detail-content {
		width: 100%;
		height: 100%;
		background-color: #fff;
		border-radius: 0;
		box-shadow: none;
		overflow-y: auto;
		position: relative;
	}

	.detail-footer {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		background-color: #fff;
		padding: 20rpx 0;
		box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
		z-index: 100;
	}

	/* 阻止背景滚动 */
	.detail-modal {
		overflow: hidden;
	}

	.detail-content {
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
	}

	.flexRight {
		display: flex;
		justify-content: flex-end;
		padding: 10px;
	}

	.jieDan {
		display: flex;
		justify-content: space-between;
		padding: 5px;
		height: 50px;
	}

	.btnFather {
		display: flex;
		justify-content: center;
		align-items: center;
	}

	/* 暂无接单人 */
	.no-receiver-text {
		font-size: 32rpx;
		color: #333;
		text-align: center;
		margin: 30rpx 0;
	}

	/* 订单信息标题 */
	.order-info-title {
		font-size: 32rpx;
		font-weight: bold;
		margin: 15px;
	}

	/* 订单信息容器 */
	.order-info-container {
		background-color: #fff;
		border-radius: 10rpx;
		padding: 20rpx;
		margin-bottom: 20rpx;
	}

	/* 信息项 */
	.info-item {
		display: flex;
		justify-content: space-between;
		padding: 15rpx 0;
		border-bottom: 1rpx solid #eee;
	}

	.label {
		font-size: 26rpx;
		color: #666;
	}

	.value {
		font-size: 26rpx;
		color: #333;
	}

	.value-copy {
		display: flex;
		align-items: center;
	}

	.copy-btn {
		padding: 0;
		margin-left: 10rpx;
		height: 14px;
		width: 14px;
		border: 0px;
		border-radius: 0px;
	}

	.copy-icon {
		width: 100%;
		height: 100%;
		align-content: center;
		display: flex;
	}

	.contact-admin {
		color: #007aff;
	}

	/* 底部按钮 */
	.footer .btn {
		flex: 1;
		height: 88rpx;
		line-height: 88rpx;
		font-size: 32rpx;
		border-radius: 8rpx;
		text-align: center;
	}

	.footer .back {
		background: #fff;
		border: 1rpx solid #2bafffd4;
		color: #2bafffd4;
		border-radius: 25px;
		margin-right: 20rpx;
		font-size: 30rpx;
	}

	.neiRong {
		background-color: #fff;
		border-radius: 10px;
		margin: 5rpx;
		box-shadow: 0px -1px 2px 2px #eee;
	}

	.header {
		padding: 15rpx 11rpx;
		position: relative;
		margin: 10rpx;
		border-radius: 6px;
	}

	.avatar {
		width: 60rpx;
		height: 60rpx;
		border-radius: 50%;
		overflow: hidden;
		margin-right: 15rpx;
		float: left;
	}

	.avatar image {
		width: 100%;
		height: 100%;
	}

	.title {
		font-size: 28rpx;
		font-weight: 500;
		display: block;
	}

	.time {
		font-size: 22rpx;
		color: #999;
	}

	.status,
	.status2,
	.status3,
	.status4 {
		position: absolute;
		right: 15rpx;
		top: 20rpx;
		padding: 6rpx 12rpx;
		font-size: 22rpx;
	}

	.status {
		background: #e1f3e8;
		color: #07c160;
	}

	.status2 {
		background: #e9f7ff;
		color: #39a0ef;
	}

	.status3 {
		background: #fff3ea;
		color: #f8ca12;
	}

	.status4 {
		background: #fff3ea;
		color: #ff7d00;
	}

	.card {
		border-radius: 12rpx;
		padding: 0 15rpx;
	}

	.card-title {
		font-size: 32rpx;
		padding: 15rpx 0;
		border-bottom: 1rpx solid #eee;
	}

	.row {
		display: flex;
		justify-content: start;
		font-size: 26rpx;
		line-height: 40rpx;
	}

	.label {
		font-weight: bold;
		display: inline-block;
	}

	.value {
		word-break: break-all;
		display: inline;
	}

	.address-box {
		padding: 15rpx 0;
	}

	.address-item {
		display: flex;
		align-items: center;
		margin-bottom: 15rpx;
	}

	.tag {
		width: 36rpx;
		height: 36rpx;
		border-radius: 50px;
		text-align: center;
		line-height: 36rpx;
		margin-right: 15rpx;
		padding: 2px;
	}

	.start {
		background: #07c160;
		color: #fff;
	}

	.end {
		background: #1989fa;
		color: #fff;
	}

	.location {
		font-size: 26rpx;
	}

	.button-row {
		display: flex;
		justify-content: space-between;
		height: 50px;
	}

	.btn {
		border-radius: 8rp;
		height: 28px;
		margin: 3px;
		line-height: 28px;
		font-size: 10px;
	}

	.note {
		background-color: #e6f7ff;
		color: #1890ff;
	}

	.image {
		background-color: #fffbe6;
		color: #faad14;
	}

	.phone {
		background-color: #e6f7ff;
		border-radius: 50%;
		width: 70rpx;
		/* 电话图标容器放大 */
		height: 70rpx;
		/* 电话图标容器放大 */
		margin: 0 15rpx;
		padding: 0;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.phone-icon {
		width: 80rpx;
		/* 电话图标放大 */
		height: 80rpx;
		/* 电话图标放大 */
	}

	.status-bar {
		margin: 20rpx;
		text-align: center;
	}

	.countdown {
		display: block;
		font-size: 24rpx;
		padding: 15rpx;
		border-radius: 8rpx;
	}

	.no-receiver {
		display: block;
		font-size: 26rpx;
		color: #999;
		margin-top: 20rpx;
	}


	.info-box {
		padding: 15rpx 0;
	}

	.info-row {
		display: flex;
		justify-content: space-between;
		font-size: 26rpx;
		line-height: 40rpx;
		color: #666;
	}

	.info-row text:last-child {
		color: #333;
	}

	.contact-row {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 15rpx 0 0;
		margin-top: 15rpx;
		border-top: 1rpx solid #eee;
		color: #007aff;
	}

	.footer {
		font-size: 30rpx;
		position: fixed;
		bottom: 10px;
		width: 100%;
		right: 10px;
		display: flex;
		background-color: #fff;
		justify-content: flex-end;
		padding: 20px 0;
	}

	.footer .back {
		background: #fff;
		border: 1rpx solid #2bafffd4;
		color: #2bafffd4;
		border-radius: 25px;
		margin-right: 20rpx;
	}

	.footer .confirm {
		background: #3c91ff;
		color: #fff;
		border: none;
	}

	.dialog-content {
		text-align: center;
		margin: 10px;
	}

	/* 标签页样式 */
	.second-tab {
		margin-top: 30rpx;
	}

	::v-deep .van-tabs--line {
		height: 80rpx !important;
	}

	::v-deep .van-tab {
		height: 80rpx !important;
		line-height: 80rpx !important;
	}

	::v-deep .van-tabs__line {
		height: 4rpx !important;
	}

	/* 加载更多样式 */
	.loading-container {
		padding: 20rpx 0;
		text-align: center;
	}

	.loading-text {
		font-size: 26rpx;
		color: #999;
	}

	.order-list-container {
		padding-bottom: 100rpx;
	}

	/* 新增：订单状态按钮样式 */
	.order-status-buttons {
		display: flex;
		justify-content: center;
		padding: 20rpx;
		margin: 20rpx;
		background-color: #fff;
		border-radius: 10rpx;
		box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
	}

	.status-btn {
		padding: 10rpx 30rpx;
		border-radius: 8rpx;
		font-size: 28rpx;
		margin: 0 10rpx;
		background-color: #f5f5f5;
		color: #666;
		border: none;
	}

	.confirm-btn {
		padding: 10rpx 30rpx;
		border-radius: 8rpx;
		font-size: 28rpx;
		margin: 0 10rpx;

		color: #FFFFFF;
		border: none;
	}

	/* 添加新的按钮样式 */
	.add-reward {
		background-color: #ff5500;
		/* 橙色，与"完成订单"按钮保持视觉一致性 */
		color: white;
		border: none;
		border-radius: 8rpx;
		padding: 6rpx 16rpx;
		font-size: 14px;
		white-space: nowrap;
		min-width: 80rpx;
		flex-shrink: 0;
	}

	/* 新增样式 - 对话框相关 */
	.dialog-overlay {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, 0.5);
		display: flex;
		justify-content: center;
		align-items: center;
		z-index: 10000;
	}

	.dialog-container {
		width: 80%;
		max-width: 600rpx;
		background-color: #fff;
		border-radius: 16rpx;
		overflow: hidden;
	}

	.dialog-header {
		padding: 30rpx 40rpx;
		border-bottom: 1rpx solid #eee;
	}

	.dialog-title {
		font-size: 32rpx;
		font-weight: bold;
		color: #333;
	}

	.dialog-content {
		padding: 40rpx;
	}

	.form-item {
		display: flex;
		align-items: center;
		margin-bottom: 30rpx;
	}

	.label {
		width: 240rpx;
		font-size: 28rpx;
		color: #666;
	}

	.value {
		font-size: 28rpx;
		color: #333;
	}

	.input-container {
		flex: 1;
		display: flex;
		align-items: center;
		border: 1rpx solid #ddd;
		border-radius: 8rpx;
		padding: 10rpx 20rpx;
	}

	.currency-symbol {
		font-size: 28rpx;
		color: #333;
		margin-right: 10rpx;
	}

	.amount-input {
		flex: 1;
		font-size: 28rpx;
		color: #333;
	}

	.dialog-footer {
		display: flex;
		border-top: 1rpx solid #eee;
	}

	.dialog-btn {
		flex: 1;
		height: 90rpx;
		font-size: 32rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.cancel-btn {
		color: #666;
	}

	.confirm-btn {
		color: #3c91ff;
		font-weight: bold;
		border-left: 1rpx solid #eee;
	}
</style>